<?php
/**
 * @file   Permission.php
 * 权限控制表
 * @date   2017-11-15 15:22:57
 * @author huwhis<huuwhois>
 * @version  0.0.1
 */

namespace app\admin\model;

class Permission extends \think\Model
{
    protected $table ='dean_permission';

//id,pid,name对象
    public function permitObject()
    {
        return $this->field('id,pid,permi_name')->select();
    }

//id,pid,name数组
    public function permitArray()
    {
        return \think\Db::table('dean_permission')->field('id,pid,permi_name')->select();
    }

//id,name,method的几个一维数组    
    public function permitMethod()
    {
        return $this->column('id,permi_method');
    }
    public function getPermitMethod($id = '')
    {
        $data = $this->permitMethod();
        return $data[$id];
    }
    public function permitName($pid = "")
    {
        return $this->where('pid', $pid)->column('permi_method,permi_name');
    }
    public function getPermitName($method = '', $pid = '')
    {
        $data = $this->permitName($pid);
        return $data[$method];
    }
//根据一个线索获取一条信息
    // public function getOnePermi($map)
    // {
    //     return $this->where($map)->field(true)->find();
    // }

    // public function getOnePermiProperty($map,$value)
    // {
    //      $data = $this->getOnePermi($map);
    //      return $data->$value;
    // }
    public function getPermiName($method = "")
    {
        $data = $this->where('permi_method', $method)->find()->permi_name;
        // var_dump($data);exit;
        return $data;
    }

//控制器
    public function permitCrtl()
    {
        return $this->where('pid', 0)->column('id,permi_method');
    }
    public function getPermitCrtl($id = '')
    {
        $data = $this->permitCrtl();
        return $data[$id];
    }
    
    public function permitCrtlId()
    {
        return $this->where('pid', 0)->column('permi_method,id');
    }
    public function getPermitCrtlId($method)
    {
        $data = $this->permitCrtlId();
        return $data[$method];
    }

    public function permiCtrlFun($ids = '')
    {
        return $this->field('id,pid,permi_method')->select($ids);
    }
}
